<div id="viewer-container"></div>
<script>
  CTS.ready(() => {
    let viewer = new CTS.Viewer('viewer-container', { sky: false, light: false }) //初始化场景
    const pointLight = new CTS.PointLight(0xffffff, 100, 100)
    pointLight.castShadow = true
    pointLight.shadow.bias = -0.01 // 尝试不同的值,必须要设置，不然会有阴影
    pointLight.position.set(0, 4, 0)
    let mesh = new CTS.Mesh(new CTS.SphereGeometry(0.1, 10, 10), new CTS.MeshBasicMaterial({ color: 'rgb(255,255,255)' }))
    mesh.position.set(0, 4, 0)
    pointLight.add(mesh)
    viewer.scene.add(pointLight)

    viewer.camera.position.set(0, 40, 0) //设置相机位置
    let modeLoader = new CTS.ModelLoder(viewer)
    modeLoader.loadModelToScene('resources/model/building.glb', model => {
      model.openCastShadow()
      model.openReceiveShadow()
    })
    let up = 0.01
    let runPoint = () => {
      pointLight.position.x += up
      if (pointLight.position.x > 10) up = up * -1
      else if (pointLight.position.x < -10) up = up * 1
    }
    viewer.addAnimate(runPoint)
  })
</script>
